
(function () {
    var dbbg = function (config) {
        this._config = config;
        this._type = this.getConfig("type"); //公文类别
        this._typeReal = this.getConfig("typeReal");//公文类别
        this._next = null;// 操作按钮布局
        this._id = this.getConfig("id"); //公文id
        this._taskName = this.getConfig("taskName"); //流程名称
        this._taskId = this.getConfig("taskId"); //待办id
        this._businessId = this.getConfig("businessId");
        this._businessType = this.getConfig("businessType");
        this.width = window.innerWidth || 320;
        this.height = window.innerHeight || 480;
        this.requestUrl = ""; //按钮操作交互地址
        this._screenindex = this.getConfig("screenindex"); //上一步页面来源 1 待办 2 通知 3 应用 4 账户

    };
    if (typeof (Clickmed) === "undefined") {
        Clickmed = {};
    }
    Clickmed.dbbg = dbbg;
    dbbg.prototype.init = function () {
        var me = this;
        var self = {
            taskId: me._taskId
        };
        window.plugins.getIntent.show(["OA", "正在获取数据"])
        var url = serverURL + "cmcp/phone/getCurrentUserTask";
        PostCP(url, self, function (dat) {
            //   console.log(dat);
            if (dat)
                me.forTask = dat["userTask"] || "";
            else {
                me.forTask = "";
            }
            me.qsbg();
        }, function () {
            me.forTask = "";
            me.qsbg();
        });

    };
  
    //请示报告待办 ，之想分别为不同的公文写一个函数 ，后来所有公文统一一个函数
    dbbg.prototype.qsbg = function () {
        var me = this;
        me.languages = null;
        baseurl = serverURL;
        var id = this._config.id || null;
        var taskId = this._config.taskId || null;
        var type = this._type || null;
        var typeReal = this._typeReal || null;
        var self = {
            id: id,
            typeReal: typeReal,
            usertask: me.forTask,
            type: type
        };
        var url = baseurl + "cmcp/phone/getDetailInfo";

        //   向后台请求数据
        PostCP(url, self, function (dat) {
            console.log((dat));
            if (!dat) {
                window.plugins.getIntent.hide();
                Alert("获取数据失败..");
                return;
            }
            me._defaultOption = dat["others"] || null;
            var url = baseurl + "cmcp/phone/getApprovalUserInfo";
            var self = {
                taskId: me._config.taskId
            };
            PostCP(url, self, function (next) {
                console.log(next);
                me._next = next;
                if (next) {
                    me._userType = next["userType"] || null;
                    me._userTask = next["userTask"] || null;
                }

                me.draw(dat); // 获取所有数据 ，开始展示
                var url = serverURL + "cmcp/phone/doGetLanguages";
                PostCP(url, null, function (dat) {
                    me.languages = dat;
                });
            }, function () {
                window.plugins.getIntent.hide();
                Alert("获取数据失败");
            });
        }, function () {
            Alert("获取数据失败");
            window.plugins.getIntent.hide();
        });
        return;

    };

    // 显示详细信息
    dbbg.prototype.draw = function (dat) {
        //     console.log(dat);
        var me = this;
        render = this._config.render || d3.select("body");
        var d1 = this._config.body || d3.select("body");
        var width = this.width;
        var scrol = d3.select("body").append("div").classed("scrol", true).style({
            position: "absolute",
            width: "100%",
            height: "100%",
            left: "100%",
            top: "0%"
        }).attr("id", "scrol");

        var warp = scrol.append("div").classed("dt_warp", true).style({
            position: "relative"
        });
        var datong_header = warp.append("div").classed("datong_header", true);

        var go_back = datong_header.append("div").classed("go_back", true);
        go_back.html("<i><img src =../../common/page/images/go_back_ico.png width =16 height=auto></i>返回");
        go_back.on(touch_s, function () {
            $(this).css("background-color", "#005ebf");
        });
        go_back.on(touch_e, function () {
            $(this).css("background-color", "");
            d1.selectAll(".scrol").transition().duration(Transiacion).style("left", width + "px");
            d3.select(render).transition().duration(Transiacion1).style("left", 0 + "px").style({
                display: "block"
            });
            setTimeout(function () {
                d1.selectAll(".scrol").remove();
                //   myScroll.refresh();
                Android.back = TempFunction.back;
            }, 100);

        });
        // 左上角返回按钮动作 
        function back1() {
            d1.selectAll(".scrol").transition().duration(Transiacion).style("left", width + "px");
            d3.select(render).transition().duration(Transiacion1).style("left", 0 + "px").style({
                display: "block"
            });
            $(".comList").remove();
            $(".mark").remove();
            setTimeout(function () {
                d1.selectAll(".scrol").remove();
                //   myscroll.refresh();
            }, 100);
            Android.back = TempFunction.back;
        }

        // Android返回键动作
        Android.back = TempFunction.back1 = back1;
        datong_header.append("h1").html(me._taskName || "");


        Redraw(dat, warp);
        function Redraw(dat, warp) {
            //     console.log(dat);
            var detailInfo = dat["detailInfo"];
            var approvalInfo = dat["approvalInfo"];
            var attachmentInfo = dat["attachmentInfo"];
            var secOptionInfo = dat["secOptionInfo"] || null;
            var scrol_ = warp.append("div").classed("scrol_", true).style({
                width: "100%",
                height: height - 100 + "px",
                postion: "relative",
                overflow: "hidden"
            }).attr("id", "scrol_");
            var datong_con = scrol_.append("div").classed("datong_con datong_con_re", true);
            var datong_con = datong_con.append("div").classed("phone_cotent", true);
            var ul = datong_con.append("ul");
            var li = ul.append("li").classed("b_btm", true).style({
                width: "100%"
            });
            var table = li.append("table").attr("cellpadding", "0").attr('cellspacing', "0").style({
                width: "100%"
            });
            ;
            var sxFlag = false;
            for (var name in detailInfo) {
                if (!detailInfo[name])
                    continue;
                //       console.log(name);
                var tr = table.append("tr");
                if (name.indexOf("raw") > -1) {
                    var str = "";
                    for (var raw in detailInfo[name]) {

                        var raw1 = raw.split("").join("&nbsp");

                        tr.append("td").html("<div >" + raw1 + "</div>").style({
                            width: "20%"
                        });
                        tr.append("td").attr({
                            width: "22%"
                        }).append("div").html(detailInfo[name][raw]).classed("extend", true);
                        ;
                    }
                    //   var dd = dl.append("dd").html(str);
                    continue;
                }


                var raw1 = name.split("").join("&nbsp");


                tr.append("td").html("<div>" + raw1 + "</div>").style({
                    width: "20%"
                });
                tr.append("td").attr("colspan", 3).append("div").html(detailInfo[name]).classed("extend", true);
            }

            for (var name in approvalInfo) {
                if (!(approvalInfo[name].length) || approvalInfo[name] == {} || approvalInfo[name] == [])
                    continue;
                var report_title = datong_con.append("div").classed("report_title", true).html(name);
                var maxLen = 0;
                var maxStr = "";
                for (var nj in approvalInfo[name]) {
                    if (!approvalInfo[name][nj])
                        continue;
                    if (approvalInfo[name][nj].length > maxLen) {
                        maxLen = approvalInfo[name][nj].length;
                        maxStr = approvalInfo[name][nj];
                    }
                    var ul = datong_con.append("ul");
                    var li = ul.append("li").classed("b_btm", true).style({
                        padding: "5px 0px"
                    });

                    var dl = li.append("dl");
                    console.log(approvalInfo[name][nj]);
                    dl.append("dd").html(approvalInfo[name][nj].replace(/\n/g, "<br>"));

                }

            }
            var buttons = [];
            if (me._next)
                var buttons = me._next["button"] || null;

            var button = warp.append("div").classed("tj_button2", true).classed("qb_btn_bg", true);
            $(".tj_button2 p input").remove();
            var tj_button = button.append("p").style({
                "text-align": "center"
            });
           
            for (var name in buttons) {
                    var Action = buttons[name]["name"] || "";
					if (Action.indexOf("起草人办理") > -1) {
                       var input = tj_button.append("input").classed("confirms", true)
                        .attr("action", buttons[name]["action"] || "")
                        .attr("type", "button")
                        .attr("mark", true)
                        .attr("requestUrl", buttons[name]["requestUrl"])
                        .attr("value", Action).style({
                            width: "26.1%",
                            margin: "0% 2%"
                        });
                    }
					else if (Action.indexOf("签批") > -1) {
                        var input = tj_button.append("input").classed("confirms", true)
                        .attr("action", buttons[name]["action"] || "")
                        .attr("type", "button")
                        .attr("mark", true)
                        .attr("requestUrl", buttons[name]["requestUrl"])
                        .attr("value", Action).style({
                            width: "26.1%",
                            margin: "0% 2%"
                        });
                    }
					else if (Action.indexOf("批示") > -1) {
                        var input = tj_button.append("input").classed("btn_agree", true)
                        .attr("action", buttons[name]["action"] || "")
                        .attr("type", "button")
                        .attr("mark", true)
                        .attr("requestUrl", buttons[name]["requestUrl"])
                        .attr("value", Action).style({
                            width: "26.1%",
                            margin: "0% 2%"
                        });
                    }
					else if (Action.indexOf("办理") > -1) {
                       var input = tj_button.append("input").classed("btn_agree", true)
                        .attr("action", buttons[name]["action"] || "")
                        .attr("type", "button")
                        .attr("mark", true)
                        .attr("requestUrl", buttons[name]["requestUrl"])
                        .attr("value", Action).style({
                            width: "26.1%",
                            margin: "0% 2%"
                        });
                    }
					else if (Action.indexOf("审核") > -1) {
                        var input = tj_button.append("input").classed("btn_agree", true)
                        .attr("action", buttons[name]["action"] || "")
                        .attr("type", "button")
                        .attr("mark", false)
                        .attr("requestUrl", buttons[name]["requestUrl"])
                        .attr("value", Action).style({
                            width: "26.1%",
                            margin: "0% 2%"
                        });
                    }
					else if (Action.indexOf("作废") > -1) {
                        var input = tj_button.append("input").classed("drop", true)
                            .attr("action", buttons[name]["action"] || "")
                            .attr("type", "button")
                            .attr("mark", buttons[name]["mark"])
                            .attr("requestUrl", buttons[name]["requestUrl"])
                            .attr("value", "作 废").style({
                                width: "26.1%"
                            });
                    }
                    else if (Action.indexOf("退回") > -1) {
                        var input = tj_button.append("input").classed("btn_back", true)
                            .attr("action", buttons[name]["action"] || "")
                            .attr("type", "button")
                            .attr("mark", buttons[name]["mark"])
                            .attr("requestUrl", buttons[name]["requestUrl"])
                            .attr("value", "退 回").style({
                                width: "26.1%"
                            });
                    }
					else if (Action.indexOf("办结") > -1) {
                        var input = tj_button.append("input").classed("other", true)
                            .attr("action", buttons[name]["action"] || "")
                            .attr("type", "button")
                            .attr("mark", false)
                            .attr("requestUrl", buttons[name]["requestUrl"])
                            .attr("value", buttons[name]["name"]).style({
                                width: "26.1%"
                            });
                    }
                    else if (Action.indexOf("确认") > -1 && me._businessType == "0015") {
                        var input = tj_button.append("input").classed("other", true)
                            .attr("action", buttons[name]["action"] || "")
                            .attr("type", "button")
                            .attr("mark", buttons[name]["mark"])
                            .attr("requestUrl", buttons[name]["requestUrl"])
                            .attr("value", "确认收函").style({
                                width: "26.1%"

                            });
                    } else {
                        var input = tj_button.append("input").classed("other", true)
                            .attr("action", buttons[name]["action"] || "")
                            .attr("type", "button")
                            .attr("mark", buttons[name]["mark"])
                            .attr("requestUrl", buttons[name]["requestUrl"])
                            .attr("value", buttons[name]["name"]).style({
                                width: "26.1%"

                            });

                    }

                $(input.node()).data("key", buttons[name]["userInfo"] || "");
            }
            if ($(".tj_button2 p input").length <= 0) {
                $(".tj_button2").remove();
                $("#scrol_").css({
                    height: height - 44 + "px"
                });
            }
            if ($(".tj_button2 p input").length <= 2) {
                $(".tj_button2 p input").css({
                    width: "40%"
                });
            }
            if ($(".tj_button2 p input").length === 3) {
                $(".tj_button2 p input").css({
                    width: "26.1%"
                });
            }
            if ($(".tj_button2 p input").length === 4) {
                $(".tj_button2 p input").css({
                    width: "20%"
                });
            }
            if ($(".tj_button2 p input").length === 5) {
                $(".tj_button2 p input").css({
                    width: "16%",
                    "margin-left": "1%",
                    "margin-right": "1%"
                });
            }

            // 下一步动作 
            $(".btn_agree").on(touch_e, function () {

                if (Flag)
                    return;
                Flag = true;
                setTimeout(function () {
                    Flag = false;
                }, 500);
                var mark = $(this).attr("mark");
                var action = $(this).attr("action");
                me.requestUrl = $(this).attr("requestUrl");
                var userInfo = $(this).data("key");
                menberSelect(mark, action, userInfo);
                return;
            });
            //作废
            $(".drop").on("click", function () {
                if (Flag)
                    return;
                Flag = true;
                setTimeout(function () {
                    Flag = false;
                }, 500);
                var mark = $(this).attr("mark");
                var action = $(this).attr("action");
                me.requestUrl = $(this).attr("requestUrl");

                navigator.notification.confirm('您确定要作废此文件么？', showConfirm, 'OA', ['取消', '确定']);
                function showConfirm(button) {
                    if (button == 2) {
                        me.confirms(action, $(".textarea").val(), mark);

                    }
                }

            });
            //其他

            $(".other").on("click", function () {
                if (Flag)
                    return;
                Flag = true;
                setTimeout(function () {
                    Flag = false;
                }, 500);
                var value = $(this).attr("value") || null;
                var mark = $(this).attr("mark");
                var action = $(this).attr("action");
                var userInfo = $(this).data("key");
                if (value && value.indexOf("回复") > -1) {
                    Alert("请在电脑上端操作");
                    return;
                }
                if (value && value.indexOf("转") > -1) {
                    //  Alert("请在电脑上端操作");
                    menberSelect(mark, action, userInfo, true);
                    return;
                }
                if (value && value.indexOf("分发") > -1) {
                    //  Alert("请在电脑上端操作");
                    menberSelect(mark, action, userInfo, true);
                    return;
                }
                if (value && value.indexOf("咨询副市长") > -1) {
                    menberSelect(mark, action, userInfo, true);
                    return;
                }
                if (value && value.indexOf("提交副市长") > -1) {
                    Alert("请在电脑上操作");
                    return;
                }
                if (value && value.indexOf("办结") > -1) {
                    me.requestUrl = $(this).attr("requestUrl");
                    //  me.confirms(action, $(".textarea").val(), mark);
                    navigator.notification.confirm('您确定要办结此文件么？', showConfirm, 'OA', ['取消', '确定']);
                    function showConfirm(button) {
                        if (button == 2) {
                            me.confirms(action, $(".textarea").val(), mark);
                        }
                    }

                    return;
                }
                var mark = $(this).attr("mark");
                var action = $(this).attr("action");
                me.requestUrl = $(this).attr("requestUrl");
                //    var value
                me.confirms(action, $(".textarea").val(), mark);
            });
            // 退回动作
            $(".btn_back").on(touch_e, function () {
                var mark = $(this).attr("mark");
                var action = $(this).attr("action");
                me.requestUrl = $(this).attr("requestUrl");
                me.confirms(action, "", mark);

            });
            // 确认收文
            $(".confirms").on(touch_e, function () {
                var mark = $(this).attr("mark");
                var action = $(this).attr("action");
                me.requestUrl = $(this).attr("requestUrl");
                var value = $(this).val();
                me.confirms(action, value, mark);
            });
            // 正文列表
            if (attachmentInfo && attachmentInfo["正文"] && attachmentInfo["正文"].length) {
                var fileList = datong_con.append("div").classed("report_title", true).html("正文");
                for (var i = 0; i < attachmentInfo["正文"].length; i++) {
                    if (!attachmentInfo["正文"][i]["name"])
                        continue;
                    var newDiv = datong_con.append("div").classed("newDiv", true)
                        .attr("url", attachmentInfo["正文"][i]["url"]).attr("fileName", attachmentInfo["正文"][i]["name"]);
                    ;
                    var len = attachmentInfo["正文"][i]["url"].split(".").length;
                    var extend = attachmentInfo["正文"][i]["url"].split(".")[len - 1];
                    var img = newDiv.append("img").attr("src", "../../common/page/images/" + extend + ".png").attr({
                        width: "25",
                        height: "22"

                    }).style("margin-left", "15px");
                    // 更改正文名字
                    var gragh = newDiv.append("p").html("正文")
                        .attr("url", attachmentInfo["正文"][i]["url"]).attr("fileName", attachmentInfo["正文"][i]["name"]);
                    // 打开正文附件
                    newDiv.on("click", function () {
                        if (Flag)
                            return;
                        Flag = true;
                        setTimeout(function () {
                            Flag = false;
                        }, 500);
                        var url = $(this).attr("url");
                        var fileName = $(this).attr("fileName");
                        url = serverURL + url.substr(1);
                        //   Alert(url);
                        window.openF(url, fileName);
                    });
                }
            }
            // 附件列表
            if (attachmentInfo && attachmentInfo["附件"] && attachmentInfo["附件"].length) {
                var fileList = datong_con.append("div").classed("report_title", true).html("附件");
                for (var i = 0; i < attachmentInfo["附件"].length; i++) {
                    var newDiv = datong_con.append("div").classed("newDiv", true)
                        .attr("url", attachmentInfo["附件"][i]["url"]).attr("fileName", attachmentInfo["附件"][i]["name"]);
                    ;
                    var len = attachmentInfo["附件"][i]["url"].split(".").length;
                    var extend = attachmentInfo["附件"][i]["url"].split(".")[len - 1];
                    var img = newDiv.append("img").attr("src", "../../common/page/images/" + extend + ".png").attr({
                        width: "25",
                        height: "22"

                    }).style("margin-left", "15px");
                    var file = newDiv.append("p").html(attachmentInfo["附件"][i]["name"])
                        .attr("url", attachmentInfo["附件"][i]["url"]).attr("fileName", attachmentInfo["附件"][i]["name"]);
                    // 打开附件
                    newDiv.on("click", function () {
                        var url = $(this).attr("url");
                        if (Flag)
                            return;
                        Flag = true;
                        setTimeout(function () {
                            Flag = false;
                        }, 500);
                        url = serverURL + url.substr(1);
                        var fileName = $(this).attr("fileName");

                        window.openF(url, fileName);

                    });
                }
            }

            // 是否隐藏顶部
            var detailInfo = dat["detailInfo"];
            var approvalInfo = dat["approvalInfo"];
            var attachmentInfo = dat["attachmentInfo"];
            if (!(objectJudge(detailInfo) || objectJudge(approvalInfo) || objectJudge(attachmentInfo))) {
                $(datong_con.node()).hide();
            }
           
            // 为页面下方增加一点空隙
            d3.select(".datong_con_re").append("p").style({
                height: "10px",
                "text-align": "center",
                background: "",
                opacity: 0,
                width: "100%"
            }).html("").attr("id", "append");

            var report_title = d3.select(".datong_con_re").append("div").classed("report_title", true).html("流程跟踪");
            report_title.style({
                background: "#f2f2f0",
                color: "#2345e6",
                "border-radius": "10px",
                "margin": "0% 2% 2% 2%"
            })
            report_title.on("click", function () {
                if (Flag)
                    return;
                Flag = true;
                me.openNew();

                setTimeout(function () {
                    Flag = false;
                }, 500);
            });
            Yscroll = new iScroll("scrol_", {hScrollbar: false, vScrollbar: false});
            window.plugins.getIntent.hide();
            setTimeout(function () {
                Yscroll.refresh();
            }, 100);
            d3.select(me._config.render).transition().duration(Transiacion1).style("left", 0 - width + "px").style("position", "absolute").style({
                display: "none"
            });
            d3.select("#scrol").transition().duration(Transiacion).style("left", "0px");
            //选择下一步之后的操作
            function menberSelect(mark, action, r, flag) {
                if (r === {}) {
                    Prompt("获取数据失败！", 1000);
                    return;
                }
                var menber = r;
                console.log(menber);
                var select = d3.select("body").append("div").classed("select", true).style({
                    width: "100%",
                    height: "100%",
                    background: "#eee",
                    position: "absolute",
                    left: width + "px",
                    //   "z-index": 10,
                    "over-follow": "hidden"
                });
                select.transition().duration(Transiacion).style("left", "0px");
                d1.select(".scrol").transition().duration(Transiacion).style("left", 0 - width + "px");
                var dt_warp = select.append("div").classed("dt_warp", true);
                var head = dt_warp.append("div").classed("datong_header", true);

                var back = head.append("div").classed("go_back", true);
                back.html("<i><img src =../../common/page/images/go_back_ico.png width =16 height=auto></i>返回");
                back.on(touch_s, function () {
                    $(this).css("background-color", "#005ebf");
                });
                // 左上角返回按钮 动作 
                back.on(touch_e, function () {
                    $(this).css("background-color", "");
                    d1.select(".scrol").transition().duration(Transiacion).style("left", 0 + "px");
                    select.transition().duration(Transiacion).style("left", width + "px");
                    setTimeout(function () {
                        select.remove();
                        // Android返回键动作更改 
                        Android.back = TempFunction.back1;
                    }, 500);
                });
                head.append("h1").html(me._taskName);
                var datong_con = dt_warp.append("div").classed("datong_con", true).style({
                    height: (height - 44) + "px",
                    background: "#fff"
                });
                var markFlag = mark;
                if (mark == "true") {

                    var ps_con = datong_con.append("div").classed("ps_con", true);
                    var tj_select = ps_con.append("div").classed("tj_select", true).style({
                    });
                    var tj_con = tj_select.append("div").classed("div_input div_input2", true);
                    var label = tj_con.append("label");
                    var commonLanguage = label.append("button").classed("commonLanguage", true).style({
                    }).html("常用语句");
                    commonLanguage.on(touch_e, function () {
                        if ($(this).css("opacity") == "0")
                            return;
                        if (Flag)
                            return;

                        Flag = true;
                        setTimeout(function () {
                            Flag = false;
                        }, 500);
                        me.Language();
                    });
                    var textarea = $("<textarea></textarea>").attr("rows", "5").addClass("textarea").attr("placeholder", "请填写意见");
                    $(tj_con.node()).append(textarea);
             
                    if (me._taskFlag) {

                        var textarea = $("<textarea></textarea>").attr("rows", "5").addClass("textarea1").attr("placeholder", "信息公开审核页办公厅审核意见").css({
                            "margin-top": "10px"
                        });
                        $(tj_con.node()).append(textarea);
                    }
                }
                datong_con.append("div").classed("report_title", true).html("选择收件人").style({
                    "text-align": "center"
                });
                if (mark == "true") {
                    var dist = 285
                    if (me._taskFlag) {
                        var dist = 390
                    }
                }
                else {
                    var dist = 122;
                }
                var list = datong_con.append("div").classed("list", true).style({
                    width: "100%",
                    height: (height - dist) + "px",
                    "over-follow": "hidden",
                    "margin": "0 auto"
                }).attr("id", "list");
                var table = list.append("div").style({
                    display: "table",
                    width: "100%"
                }).attr("cellpadding", "0").attr("cellspacing", "0");
                listTable(menber, table);
                //下一位收件人列表
                function listTable(menber, table) {
                    for (var party in menber) {
                        if (!menber[party].length)
                            continue;
                        var tr = table.append("div").classed("sjt_tit", true).html(party);
                        ;
                        var tr1 = table.append("div").classed("sjr_name", true);
                        var ul = tr1.append("ul");
                        for (var j = 0; j < menber[party].length; j++) {
                            var li = ul.append("li").attr("action", menber[party][j]["action"])
                                .attr("roleCode", menber[party][j]['roleCode']).attr("userName", menber[party][j]["userName"]);
                            li.html("<i class= choose_ico></i>" + menber[party][j]["userName"]);
                            if (flag) {
                                li.on("click", function () {
                                    if (Flag)
                                        return;

                                    Flag = true;
                                    setTimeout(function () {
                                        Flag = false;
                                    }, 500);
                                    if (!$(this).hasClass("sel1")) {
                                        $(this).addClass("sel1");
                                        d3.select(this).select("i").classed("choosed_ico", true).classed("choose_ico", false);
                                    }
                                    else {
                                        $(this).removeClass("sel1");
                                        d3.select(this).select("i").classed("choose_ico", true).classed("choosed_ico", false);
                                    }

                                });
                            }
                            else {
                                li.on("click", function () {
                                    if (Flag)
                                        return;

                                    Flag = true;
                                    setTimeout(function () {
                                        Flag = false;
                                    }, 500);
                                    $("li").removeClass("sel1");
                                    $(this).addClass("sel1");
                                    d3.selectAll("i").classed("choosed_ico", false).classed("choose_ico", true);
                                    d3.select(this).select("i").classed("choosed_ico", true).classed("choose_ico", false);
                                });
                            }

                        }

                    }
                }

// 添加列表滑动效果
                Myscroll = new iScroll("list", {hScrollbar: false, vScrollbar: false});
                var tj_button = datong_con.append("div").classed("tj_button2", true).classed("qb_btn_bg", true).style({
                    bottom: "0px"
                });


                var cancel = tj_button.append("input").classed("btn_back", true).attr("type", "button")
                    .attr("value", "取  消");
                var ensure = tj_button.append("input").classed("btn_agree", true).attr("type", "button")
                    .attr("value", "确  认");
                // 选择下一位，确认 
                ensure.on(touch_e, function () {
                        if (markFlag == "true" && (!$(".textarea").val().length)) {
							Prompt("请填写审批意见！", 1000);
                            return;
                        }
                    if (Flag)
                        return;
                    Flag = true;
                    setTimeout(function () {
                        Flag = false;
                    }, 500);
                    var approvalFlag = null;
                    var roleCodes = null;
                    var userName = null;
                    if (flag) {
                        approvalFlag = action;
                        $(".sjr_name ul li").each(function () {
                            if ($(this).hasClass("sel1")) {
                                if (!roleCodes) {
                                    roleCodes = $(this).attr("roleCode");
                                    userName = $(this).attr("userName");
                                }
                                else {
                                    roleCodes = roleCodes + "," + $(this).attr("roleCode");
                                    userName = userName + "</br>" + $(this).attr("userName");
                                }
                            }
                        });
                    }
                    else {
						 approvalFlag = action;
                        $(".sjr_name ul li").each(function () {
                            if ($(this).hasClass("sel1")) {
                                roleCodes = $(this).attr("roleCode");
                                userName = $(this).attr("userName");
                            }
                        });
                    }
                    // 没有选择下一位，提示信息
                    if (!approvalFlag || !roleCodes) {
                        Prompt("请选择下一位收件人！", 1000);
                        return;
                    }
                    var url = baseurl + "cmcp/phone/approvalInfo";
                    //      url = "test.json";
                    var self = {
                        approvalFlag: approvalFlag,
                        taskId: me._taskId,
                        id: me._id,
                        businessType: me._typeReal,
                        type: me._type,
                        requestUrl: me.requestUrl || null,
                        roleCodes: roleCodes,
                        mark: $(".textarea").val() || ""
                    };
                    if (me._taskFlag) {
                        var self = {
                            approvalFlag: approvalFlag,
                            taskId: me._taskId,
                            id: me._id,
                            businessType: me._typeReal,
                            type: me._type,
                            requestUrl: me.requestUrl || null,
                            roleCodes: roleCodes,
                            mark: $(".textarea").val(),
                            mark1: $(".textarea1").val()

                        };
                    }
                    console.log(self);
                    // 向后台提交选择的下一位收件人信息
                    window.plugins.getIntent.show(["OA", "正在提交."]);
                    PostCP(url, self, function (data, status) {
                        window.plugins.getIntent.hide();
                        console.log(data);
                        if (!data) {
                            Prompt("操作失败，请重新登录。", 1000);
                            return;
                        }
                        if (data != "success") {
                            Prompt("该文件已被处理！", 1000);
                            return;
                        }
                        Prompt("成功提交给</br>" + userName, 1000);
                        // 退回到待办列表
                        select.transition().duration(Transiacion).style("left", width + "px");
                        d1.selectAll(".scrol").transition().duration(Transiacion).style("left", 0 + "px");
                        setTimeout(function () {
                            select.remove();
                        }, 500);
                        setTimeout(function () {

                            d3.select(render).transition().duration(Transiacion1).style("left", 0 + "px").style("position", "absolute").style({
                                display: "block"
                            });
                            d1.selectAll(".scrol").transition().duration(Transiacion).style("left", width + "px");
                            setTimeout(function () {
                                d1.selectAll(".scrol").remove();
                            }, Transiacion);
                            // Android返回键动作更改并重新刷新待办列表
                            window.localStorage.status = "true";
                            Android.back = TempFunction.back;
                        }, 0);
                    }, function () {

                        window.plugins.getIntent.hide();
                        Alert("提交失败！");

                    });


                });
                // 点击取消 
                cancel.on(touch_e, function () {
                    if (Flag)
                        return;
                    Flag = true;
                    setTimeout(function () {
                        Flag = false;
                    }, 500);
                    // 退回到详细页面 
                    select.transition().duration(Transiacion).style("left", width + "px");
                    d1.select(".scrol").transition().duration(Transiacion).style("left", 0 + "px");
                    setTimeout(function () {
                        select.remove();
                        // Android 返回键动作更改
                        Android.back = TempFunction.back1;
                    }, Transiacion);
                });
                // Android 返回键动作
                function back2() {
                    $(".comList").remove();
                    $(".mark").remove();
                    select.transition().duration(Transiacion).style("left", width + "px");
                    d1.select(".scrol").transition().duration(Transiacion).style("left", 0 + "px");
                    setTimeout(function () {
                        select.remove();
                    }, 500);
                    Android.back = TempFunction.back1;
                }

                Android.back = TempFunction.back2 = back2;
            }

        }
    };
    // 常用语列表
    dbbg.prototype.Language = function () {
        var me = this;
        var value = $(".textarea").val();
        var url = serverURL + "cmcp/phone/doGetLanguages";
        var dat = me.languages;
        if (!dat["languages"] || !dat["languages"].length) {
            Alert("您还没有常用语句，请到后台维护您的常用语");
            return;
        }
        comList = dat["languages"] || comList;
        var List = d3.select("body").append("div").classed("comList", true);
        var head = List.append("div").classed("head", true).html("常用语列表");
        var con = List.append("div").classed("con", true).attr("id", "comList").style({
            "border-radius": "3px",
            background: "#ccdfee"
        });
        var ul = con.append("ul").style("overflow", "hidden").style({
            width: "80%",
            position: "absolute",
            left: "10%"
        });
        ul.append("li").style({
            height: "10px",
            "border-bottom": ".4px solod #838383"
        });
        for (var i = 0; i < comList.length; i++) {
            ul.append("li").html("<img src=../../common/page/images/mr.png>   " + comList[i]);
        }
        ul.append("li").style({
            height: "10px",
            "border-bottom": ".4px solod #838383"
        });
        new iScroll("comList", {hScrollbar: false, vScrollbar: false});
        var html = "";
        $(".comList ul li").each(function () {
            $(this).on("click", function () {
                if (Flag)
                    return;
                Flag = true;
                setTimeout(function () {
                        Flag = false;
                    },
                    500
                )
                $(this).toggleClass("selec");
                var that = d3.select(this);
                if ($(this).hasClass("selec")) {
                    html += $(this).text() + " ";
                    that.select("img").attr("src", "../../common/page/images/xz.png");
                } else {
                    html = html.replace($(this).text() + " ", "");
                    that.select("img").attr("src", "../../common/page/images/mr.png");
                }
                $(".textarea").val(value + html);

            });
        });
        var but = List.append("div").classed("but", true);
        var p = but.append("p").style({
            background: '#afbcca'
        });
        var but2 = p.append("button").style({
            width: "100px",
            height: "35px",
            background: "#d76856",
            color: "#ffe",
            "border-radius": "7px",
            "font-size": "18px",
            "margin": "10px"
        }).html("取 消");
        var but1 = p.append("button").style({  // 这里应该把样式写到 css 里
            width: "100px",
            height: "35px",
            border: '0px solid #70ab67',
            background: '#65d756',
            color: "#ffe",
            "border-radius": "7px",
            "font-size": "18px",
            "margin": "10px"
        }).html("确 认");

        but1.on("click", function () {
            Flag = true;
            List.remove();

            setTimeout(function () {
                Flag = false;
            }, 1000);

        });

        but2.on("click", function () {
            Flag = true;
            List.remove();

            $(".textarea").val(value);
            setTimeout(function () {
                Flag = false;
            }, 1000);

        });


    };
    // 点击操作按钮 执行动作
    dbbg.prototype.confirms = function (approvalFlag, value, mark) {
        //    console.log(approvalFlag);
        var me = this;
        if (mark === "true") {  // 判断是否必须输入意见
            me.advice(approvalFlag, value, mark);
            return;
        }
        var d1 = this._config.body || d3.select("body");
        var me = this;
        var url = baseurl + "cmcp/phone/approvalInfo";
        var self = {
            approvalFlag: approvalFlag,
            taskId: me._taskId,
            id: me._id,
            businessType: me._typeReal || "",
            requestUrl: me.requestUrl || null,
            type: me._type,
            roleCodes: null,
            mark: value || ""
        };
        console.log(self);
        // 向后台提交内容
        window.plugins.getIntent.show(["OA", "正在提交"])
        PostCP(url, self, function (data, status, e) {
            console.log(data);
            if (!data) {
                Prompt("操作失败，请重新登录。", 1000);
                return;
            }
            window.plugins.getIntent.hide();
            if (data != "success") {
                Prompt("该文件已被处理！", 1000);
                return;
            }

            Prompt("操作成功！", 1000);
            // 成功后返回待办列表
            setTimeout(function () {

                d3.select(me._config.render).transition().duration(Transiacion1).style("left", 0 + "px").style("position", "absolute").style({
                    display: "block"
                });
                d1.selectAll(".scrol").transition().duration(Transiacion).style("left", width + "px");
                setTimeout(function () {
                    d1.selectAll(".scrol").remove();
                    Android.back = TempFunction.back;
                }, Transiacion);
                window.localStorage.status = "true";
            }, 1000);
        }, function () {
            // 失败显示提示信息
            window.plugins.getIntent.hide();
            Prompt("操作失败，请重新登录。", 1000);
        });

    };
    // 必须输入意见
    dbbg.prototype.advice = function (approvalFlag, value, mark) {
        var me = this;
        var d1 = this._config.body || d3.select("body");
        var select = d3.select("body").append("div").classed("select", true).style({ // 这里的样式应该写在css里
            width: "100%",
            height: "100%",
            background: "#eee",
            position: "absolute",
            left: width + "px",
            //   "z-index": 10,
            "over-follow": "hidden"
        });
        select.transition().duration(Transiacion).style("left", "0px");
        d1.select(".scrol").transition().duration(Transiacion).style("left", 0 - width + "px");
        var dt_warp = select.append("div").classed("dt_warp", true);
        var head = dt_warp.append("div").classed("datong_header", true);
        var back = head.append("div").classed("go_back", true);
        back.html("<i><img src =../../common/page/images/go_back_ico.png width =16 height=auto></i>返回");
        back.on(touch_s, function () {
            $(this).css("background-color", "#005ebf");
        });
        // 左上角返回按钮 动作 
        back.on(touch_e, function () {
            $(this).css("background-color", "");
            d1.select(".scrol").transition().duration(Transiacion).style("left", 0 + "px");
            select.transition().duration(Transiacion).style("left", width + "px");
            setTimeout(function () {
                select.remove();
                // Android返回键动作更改 
                Android.back = TempFunction.back1;
            }, 500);
        });
        function back3() {
            select.transition().duration(Transiacion).style("left", width + "px");
            d1.select(".scrol").transition().duration(Transiacion).style("left", 0 + "px");
            setTimeout(function () {
                $(".comList").remove();
                $(".mark").remove();
                select.remove();
                // Android 返回键动作更改
                Android.back = TempFunction.back1;
            }, Transiacion);
        }

        Android.back = TempFunction.back3 = back3;
        head.append("h1").html(me._taskName);
        var datong_con = dt_warp.append("div").classed("datong_con", true).style({
            height: (height - 44) + "px",
            background: "#fff"
        });
        var ps_con = datong_con.append("div").classed("ps_con", true);
        var tj_select = ps_con.append("div").classed("tj_select", true).style({
        });
        var tj_con = tj_select.append("div").classed("div_input div_input2", true);
        var label = tj_con.append("label");
        var commonLanguage = label.append("button").classed("commonLanguage", true).style({
        }).html("常用语句");
        commonLanguage.on(touch_e, function () {
            if ($(this).css("opacity") == "0")
                return;
            if (Flag)
                return;

            Flag = true;
            setTimeout(function () {
                Flag = false;
            }, 500);
            me.Language();
        });
        var textarea = $("<textarea></textarea>").attr("rows", "5").addClass("textarea").attr("placeholder", "请填写意见");
        $(tj_con.node()).append(textarea);
        var tj_button = datong_con.append("div").classed("tj_button2", true).classed("qb_btn_bg", true).style({
            bottom: "0px"
        });


        var cancel = tj_button.append("input").classed("btn_back", true).attr("type", "button")
            .attr("value", "取  消");
        var ensure = tj_button.append("input").classed("btn_agree", true).attr("type", "button")
            .attr("value", "确  认");
        ensure.on(touch_e, function () {
            if (Flag)
                return;
            Flag = true;
            setTimeout(function () {
                Flag = false;
            }, 500);
            if (!($(".textarea").val().length)) {
                Prompt("请输入意见！", 1000);
                return;
            }
            var url = baseurl + "cmcp/phone/approvalInfo";
            var self = {
                approvalFlag: approvalFlag,
                taskId: me._taskId,
                id: me._id,
                businessType: me._typeReal,
                requestUrl: me.requestUrl || null,
                type: me._type,
                roleCodes: null,
                mark: $(".textarea").val() || ""
            };
            // 向后台提交内容
            console.log(url, self);
            window.plugins.getIntent.show(["OA", "正在提交."])
            PostCP(url, self, function (data, status, e) {
                console.log(data);
                window.plugins.getIntent.hide();
                if (!data) {
                    Prompt("操作失败，请重新登录。", 1000);
                    return;
                }
                if (data != "success") {
                    Prompt("该文件已被处理！", 1000);
                    return;
                }

                Prompt("操作成功！", 1000);
                // 成功后返回待办列表
                select.transition().duration(Transiacion).style("left", width + "px");
                d1.selectAll(".scrol").transition().duration(Transiacion).style("left", 0 + "px");
                setTimeout(function () {
                    select.remove();

                }, 500);
                setTimeout(function () {

                    d3.select(me._config.render).transition().duration(Transiacion1).style("left", 0 + "px").style("position", "absolute").style({
                        display: "block"
                    });
                    d1.selectAll(".scrol").transition().duration(Transiacion).style("left", width + "px");
                    setTimeout(function () {
                        d1.selectAll(".scrol").remove();
                    }, Transiacion);
                    // Android返回键动作更改并重新刷新待办列表
                    window.localStorage.status = "true";
                    Android.back = TempFunction.back;
                }, 0);
            }, function () {
                // 失败显示提示信息 
                Prompt("操作失败，请重新登录。", 1000);

                window.plugins.getIntent.hide();
                //        console.log(self);
            });

        });
        cancel.on(touch_e, function () {
            if (Flag)
                return;
            Flag = true;
            setTimeout(function () {
                Flag = false;
            }, 500);
            // 退回到详细页面 
            select.transition().duration(Transiacion).style("left", width + "px");
            d1.select(".scrol").transition().duration(Transiacion).style("left", 0 + "px");
            setTimeout(function () {
                select.remove();
                // Android 返回键动作更改
                Android.back = TempFunction.back1;
            }, Transiacion);
        });
    };

    //打开流程跟踪
    dbbg.prototype.openNew = function () {
        var me = this;
        var href = location.href;
        var len = href.lastIndexOf("/");
        var url = href.substr(0, len - 4) + "lcgz/lcgz.html?id=" + me._id + "&typeReal=" + me._typeReal + "&screenindex=" + me._screenindex;
        window.openViewB(url);
    };
	
    dbbg.prototype.getConfig = function (key) {
        if (this._config == null) {
            return null;
        } else {
            if (typeof (this._config[key]) != "undefined") {
                return this._config[key];
            } else {
                return null;
            }
        }
    };
})
();